package com.bondex.charter.service;

import com.bondex.charter.dao.CharterUserOperateLogMapper;
import com.bondex.charter.po.CharterUserOperateLogVO;
import com.bondex.charter.pojo.UserOperateLogSearchParam;
import com.bondex.global.pojo.PageTableParamT;
import com.bondex.global.pojo.ResultT;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * 用户操作日志
 * Created by daixw 20210917
 */
@Service
public class UserOperateLogService extends BaseService {
	private Logger logger = LoggerFactory.getLogger(UserOperateLogService.class);
	@Resource
	private CharterUserOperateLogMapper charterUserOperateLogMapper;

	/**
	 * 插入日志信息
	 */
	public void insertCharterUserOperateLog(CharterUserOperateLogVO record) {
		charterUserOperateLogMapper.insertCharterUserOperateLog(record);
	}

	/**
	 * 用户操作日志查询接口
	 * @return
	 */
	public ResultT<List<CharterUserOperateLogVO>> findCharterUserOperateLogList(PageTableParamT<UserOperateLogSearchParam> param) {
		ResultT<List<CharterUserOperateLogVO>> logResult = new ResultT<>(false);
		try {
			if (param == null) param = new PageTableParamT<>();
			initPageTableParam(param);
			int nTotal = charterUserOperateLogMapper.findCharterUserOperateLogListCount(param);
			List<CharterUserOperateLogVO> oList = nTotal > 0 ? charterUserOperateLogMapper.findCharterUserOperateLogList(param) : new ArrayList<>();
			logResult.setSuccess(true);
			logResult.setData(oList);
			logResult.setTotal(nTotal);
		} catch (Exception e) {
			logResult.setSuccess(false);
			logResult.setMessage(e.getMessage());
		}
		return logResult;
	}


}
